/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("equip_spotmaintworkorder",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;      
using MES.Equipment.IServices;
using VOL.Core.Filters;

namespace MES.Equipment.Controllers
{
    public partial class equip_spotmaintworkorderController
    {
        private readonly Iequip_spotmaintworkorderService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public equip_spotmaintworkorderController(
            Iequip_spotmaintworkorderService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }

        /// <summary>
        /// 定时任务生成点检保养工单
        /// </summary>
        /// <returns></returns>
        [ApiTask]
        [HttpGet, HttpPost, Route("generateSpotWorkOrder")]
        public IActionResult GenerateSpotWorkOrder()
        {
            return Content(_service.CreateSpotWorkOrder());
        }

        ///// <summary>
        ///// 工单状态变更
        ///// </summary>
        ///// <param name="code"></param>
        ///// <returns></returns>
        //[HttpGet, Route("changeUpdate")]
        //public string ChangeUpdate(string spotMaintWorkOrderId, string status, string remark)
        //{
        //    Equip_SpotMaintWorkOrder workOrder = new Equip_SpotMaintWorkOrder()
        //    {
        //        SpotMaintWorkOrderId = new Guid(spotMaintWorkOrderId),
        //        Status = Convert.ToInt32(status),
        //        Remark = remark,
        //        ModifyDate = DateTime.Now,
        //    };
        //    _spotMaintWorkOrderRepository.Update(workOrder, x => new { x.Status, x.ModifyDate, x.Remark }, true);
        //    return "变更成功！";
        //}
    }
}
